﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Laby
{
    class Cell
    {
        public List<Cell> Linked { get; set; }
        public List<Cell> Neighbors { get; set; }
        public bool IsVisited { get; set; }

        public Cell()
        {
            Neighbors = new List<Cell>();
            Linked = new List<Cell>();
            IsVisited = false;
        }


        public void AddLinked(Cell c)
        {
            Linked.Add(c);
        }

        public void AddNeighbors(Cell c)
        {
            Neighbors.Add(c);
        }

        public bool IsLinked(Cell c)
        {
            return Linked.Contains(c);
        }

        public List<Cell> GetNeighbors() 
        {
            return Neighbors;
        }

        public List<Cell> GetLinked()
        {
            return Linked;
        }

        public void randomizeNeighbors(Random rnd)
        {
            for (int i = 0; i < Neighbors.Count; i++)
            {
                int j = rnd.Next(0, i);
                Cell tmp = Neighbors[j];
                Neighbors[j] = Neighbors[i];
                Neighbors[i] = tmp;
            }
        }
    }
}
